﻿using BasicInformation.Domain;
using BasicInformation.Infrastructure.Interface;
using BasicInformation.ReadAPI.Application.Command.VehicleCommand;
using MediatR;

namespace BasicInformation.ReadAPI.Application.CommandHandler.VehicleCommandHandler
{
    public class VehicleInfoCommandHandler : IRequestHandler<VehicleInfoCommand, Vehicle>
    {
        private readonly IVehicleRepository vehicleRepository;

        public VehicleInfoCommandHandler(IVehicleRepository vehicleRepository)
        {
            this.vehicleRepository = vehicleRepository;
        }

        async Task<Vehicle> IRequestHandler<VehicleInfoCommand, Vehicle>.Handle(VehicleInfoCommand request, CancellationToken cancellationToken)
        {
            var info = await vehicleRepository.Get(request.Id);
            return info;
        }
    }
}
